package com.beijiteshop.shop.ui.detail.adapter

import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.viewpager.widget.PagerAdapter
import com.beijiteshop.libcommon.utils.ImageLoadUtil

/**
 * @Author LiaoZhongKai
 * @Date 2021/3/4 15:17
 * @Description 图片滑动展示适配器
 */
class ImageGalleryAdapter(private val urls: MutableList<String>) : PagerAdapter(){

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val imageView = ImageView(container.context)
        ImageLoadUtil.loadImage(urls[position],imageView)
        container.addView(imageView)
        return imageView
    }

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view == `object`
    }

    override fun getCount(): Int {
        return urls.size
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {

    }

}